#include "../inc/main_widget.h"

main_widget::main_widget(QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	this->SetTabWidget();
}

main_widget::~main_widget()
{

}

void main_widget::on_btnWrite_clicked(){
	write_mblog_widget* wmw=new write_mblog_widget();
	wmw->my_parent=this;
	wmw->showMaximized();
	this->hide();
}

void main_widget::SetTabWidget(){
	this->nw=new news_widget(this->ui.tabNews);
	this->mmw=new my_mblog_widget(this->ui.tabMy);
	this->msw=new mystar_widget(this->ui.tabStars);
	this->mfw=new myfans_widget(this->ui.tabFans);
	this->nw->SetSoftKeys(this);
	connect(this->ui.twMain, SIGNAL(currentChanged(int)), this, SLOT(on_twMain_changed(int)));
}

void main_widget::on_twMain_changed(int i){
	if(this->actions().contains(this->nw->actRef))
		this->removeAction(this->nw->actRef);
	if(this->actions().contains(this->mmw->actRef))
		this->removeAction(this->mmw->actRef);
	if(this->actions().contains(this->msw->actRef))
		this->removeAction(this->msw->actRef);
	if(this->actions().contains(this->mfw->actRef))
		this->removeAction(this->mfw->actRef);
	switch(i){
		case 0:
			this->nw->SetSoftKeys(this);
			break;
		case 1:
			this->mmw->SetSoftKeys(this);
			break;
		case 2:
			this->msw->SetSoftKeys(this);
			break;
		case 3:
			this->mfw->SetSoftKeys(this);
			break;
	}
}
